package org.testis.testdriver.parser;

import org.testis.orm.conditionhandler.ConditionHandlerFactory;
import org.testis.testdriver.AtofEnumaration;
import org.testis.testdriver.ITestBuilder;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import org.orm.PersistentException;
import org.testis.orm.refinedclasses.TestCaseGroupRefined;
import org.testis.orm.refinedclasses.TestDesignTreeNode;

/**
 *
 * @author barisergun
 */
public class TestDriverTestCaseGroupRefinedParsing extends TestDriverAbstractParsingStrategy {

    public TestDriverTestCaseGroupRefinedParsing(ITestBuilder builder,
            TestDesignTreeNode currentNode) {
        m_builder = builder;
        m_currentNode = currentNode;

        if (m_currentNode.isClone()) {
            m_cloneString = " [clone]";
        }
    }

    @Override
    public void parseCurrentNode() throws PersistentException {
        TestCaseGroupRefined testPart =
                (TestCaseGroupRefined) m_currentNode.getObject();
        m_builder.buildTestPart(String.valueOf(m_currentNode.getId()),
                testPart.getName() + m_cloneString,
                testPart.getReference().getDescription(),
                AtofEnumaration.TestPartType.TestCaseGroup,
                String.valueOf(m_currentNode.getParent().getId()));
        m_builder.setTestPartDependency(String.valueOf(m_currentNode.getId()),
                null,
                true);
        LinkedList<String> condList = getConditionsOfTestPart();

        m_builder.setTestPartConditions(String.valueOf(m_currentNode.getId())
                , condList);

    }
}
